//
//  KKVkontakteManager.m
//  LoginTest
//
//  Created by kievkao on 5/17/14.
//  Copyright (c) 2014 kievkao. All rights reserved.
//

#import "KKVkontakteManager.h"
#import "VKSdk.h"
#import "WebFormHandler.h"

@implementation KKVkontakteManager

- (id)init
{
    self = [super init];
    
    if (self) {
        [VKSdk initializeWithDelegate:self andAppId:@"4367180"];
    }
    
    return self;
}

- (void)loginWithCompletion:(KKCompleteBlock)completion
{
    [[WebFormHandler sharedInstance] setWebFormType:1];
    
    self.completion = completion;
    //[VKSdk authorize:self.permissions];
    [VKSdk authorize:self.permissions revokeAccess:YES forceOAuth:YES];
}

- (void)vkSdkReceivedNewToken:(VKAccessToken *)newToken
{
    if (self.completion) {
        self.completion(nil, @{@"token": newToken});
    }
}

- (void)vkSdkUserDeniedAccess:(VKError *)authorizationError
{
    if (self.completion) {
        self.completion([NSError errorWithVkError:authorizationError], nil);
    }
}

- (void)vkSdkAcceptedUserToken:(VKAccessToken *)token
{
    NSLog(@"d");
}

- (void)vkSdkNeedCaptchaEnter:(VKError *)captchaError
{
    NSLog(@"d");
}



- (void)vkSdkRenewedToken:(VKAccessToken *)newToken
{
    NSLog(@"d");
}

- (void)vkSdkShouldPresentViewController:(UIViewController *)controller
{
    NSLog(@"d");
}

- (void)vkSdkTokenHasExpired:(VKAccessToken *)expiredToken
{
    NSLog(@"d");
}



@end
